<?php

namespace app\api\controller;
use app\BaseController;
use app\api\model\Article as ArticleModel;
use app\api\validate\Article as ArticleValidate;
use app\api\exception\ParameterException;

class Article extends Base {

  public function __construct() {
    $this->model = new ArticleModel();
  }

  public function status() {
    
    $status = input('post.status', 0, 'intval');
    $id = input('post.id', '', 'intval');
    $this->model->setStatusById($id, $status);
    return success();

  }

  public function create() {
    $data = input('post.');
    $data['content'] = input('post.content', '', null);
    if(isset($data['create_time'])) {
     $data['create_time'] = convertTime($data['create_time']);
    }
    if(!empty($data['id'])) {
      $this->model->update($data);
    } else {
      $this->model->save($data);
    }
    return success();
  }

}